bitkeeper revision 1.782 (40508b99QPPOLTn2qbkS5lxuckFyKA)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 11 Mar 2004 15:54:01 +0000 (15:54 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 11 Mar 2004 15:54:01 +0000 (15:54 +0000)
vif.h, network.c, domain.c:
  Purge VFR rules when a domain dies.

xen/common/domain.c
xen/common/network.c
xen/include/xeno/vif.h

index d226c52d5ffbfe61b4dcb18d059a68384a42b06c..acc537a10399a4bd54492d5a1075b87bd3d7d363 100644 (file)
@@ -153,6 +153,8 @@ void __kill_domain(struct task_struct *p)
 
     destroy_event_channels(p);
 
+    delete_all_domain_vfr_rules(p);
+
     /*
      * Note this means that find_domain_by_id may fail, even when the caller
      * holds a reference to the domain being queried. Take care!
index d13c079e47dbc49f148f5942ac7411a504b08848..cf960c82b9732bb760d94c43c939530b70e86621 100644 (file)
@@ -298,9 +298,8 @@ int delete_net_rule(net_rule_t *rule)
 
     write_lock(&net_rule_lock);
 
-    for ( pent = &net_rule_list; pent != NULL; pent = &ent->next )
+    for ( pent = &net_rule_list; (ent = *pent) != NULL; pent = &ent->next )
     {
-        ent = *pent;
         if ( memcmp(rule, &ent->r, sizeof(net_rule_t)) == 0 )
         {
             *pent = ent->next;
@@ -312,6 +311,27 @@ int delete_net_rule(net_rule_t *rule)
     write_unlock(&net_rule_lock);
     return 0;
 }
+
+void delete_all_domain_vfr_rules(struct task_struct *p)
+{
+    net_rule_ent_t **pent, *ent;
+
+    write_lock(&net_rule_lock);
+
+    for ( pent = &net_rule_list; (ent = *pent) != NULL; )
+    {
+        if ( (ent->r.src_dom == p->domain) || (ent->r.dst_dom == p->domain) )
+        {
+            *pent = ent->next;
+            kmem_cache_free(net_rule_cache, ent);
+            continue;
+        }
+
+        pent = &ent->next;
+    }
+
+    write_unlock(&net_rule_lock);
+}
  
 static char *idx_to_name(unsigned int idx)
 {
index 0cd2e4dec4ec701462773b11b3cd9782238474e8..0da8b2bd998b4ddca632d65381e4e9d8247c3e27 100644 (file)
@@ -99,6 +99,7 @@ void destroy_net_vif(net_vif_t *vif);
 void unlink_net_vif(net_vif_t *vif);
 net_vif_t *net_get_target_vif(u8 *data, unsigned int len, net_vif_t *src_vif);
 net_vif_t *find_net_vif(domid_t dom, unsigned int idx);
+void delete_all_domain_vfr_rules(struct task_struct *p);
 
 /*
  * Return values from net_get_target_vif: